from doubancon.doubanservice import getDoubanPeople
from doubancon.models import Douban_Access_Token

def getNameById(uid):
    return getDoubanPeople(uid)['db:uid']['$t']

def getDoubanInfoById(uid):
    """
    return the Douban_Access_Token
    """
    tmpc = Douban_Access_Token.all().filter("doubanid = ",uid).count()
    if tmpc == 0:
        return None
    if tmpc == 1:
        return Douban_Access_Token.all().filter("doubanid = ",uid)[0]
    raise Exception("one douban id corresponse to more than a item")
